gradient descent implementation in python